const fs = require('fs');
const {
    startServer
} = require('./SERVER/Http');
const config = new (class {
    constructor() {
        this.init();
        this.record = {};
    }
    _init(file,name) {
        if (fs.existsSync(file)) {
            this[name] = JSON.parse(fs.readFileSync(file,'utf-8'));
        }
    }
    init() {
        let initList = [
            {
                file: './conf/record.json',
                name: 'record'
            }
        ];
        initList.forEach(o => this._init(o.file,o.name));
        let id = setInterval(() => {
            initList.forEach(o => {
                fs.writeFileSync(o.file,JSON.stringify(this[o.name]),'utf-8');
            },1000 * 60);
        });
    }
});

startServer(7077,function (method,path,data,{req,res}) {
    if (path.startsWith('/record')) {
        res.end("haha");
    }
});

